﻿using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;

namespace HML
{
    /// <summary>
    /// DropDownListPlus选项区域选项风格
    /// </summary>
    [TypeConverter(typeof(PropertyOrderConverter))]
    public class DropDownListPlusContentItemsStyle
    {
        #region 属性

        private Color itemBorderColor = Color.FromArgb(110, 153, 153);
        /// <summary>
        /// 选项边框颜色
        /// </summary>
        [Description(" 选项边框颜色")]
        [PropertyOrder(-197)]
        [DefaultValue(typeof(Color), "110, 153, 153")]
        public Color ItemBorderColor
        {
            get { return this.itemBorderColor; }
            set
            {
                if (this.itemBorderColor == value)
                    return;

                this.itemBorderColor = value;
                this.Invalidate();
            }
        }

        private Color itemBackColor = Color.FromArgb(130, 178, 178);
        /// <summary>
        /// 选项背景颜色
        /// </summary>
        [Description(" 选项背景颜色")]
        [PropertyOrder(-196)]
        [DefaultValue(typeof(Color), "130, 178, 178")]
        public Color ItemBackColor
        {
            get { return this.itemBackColor; }
            set
            {
                if (this.itemBackColor == value)
                    return;

                this.itemBackColor = value;
                this.Invalidate();
            }
        }

        private Color itemTextColor = Color.White;
        /// <summary>
        /// 选项文本颜色
        /// </summary>
        [Description(" 选项文本颜色")]
        [PropertyOrder(-194)]
        [DefaultValue(typeof(Color), "White")]
        public Color ItemTextColor
        {
            get { return this.itemTextColor; }
            set
            {
                if (this.itemTextColor == value)
                    return;

                this.itemTextColor = value;
                this.Invalidate();
            }
        }

        private bool itemClearVisible = false;
        /// <summary>
        /// 选项是否显示清除按钮
        /// </summary>
        [Description("选项是否显示清除按钮")]
        [PropertyOrder(-193)]
        [DefaultValue(false)]
        public bool ItemClearVisible
        {
            get { return this.itemClearVisible; }
            set
            {
                if (this.itemClearVisible == value)
                    return;

                this.itemClearVisible = value;
                this.InitializeInvalidate();
            }
        }

        private Color itemClearBackColor = Color.Empty;
        /// <summary>
        /// 清除按钮背景颜色
        /// </summary>
        [Description(" 清除按钮背景颜色")]
        [PropertyOrder(-192)]
        [DefaultValue(typeof(Color), "")]
        public Color ItemClearBackColor
        {
            get { return this.itemClearBackColor; }
            set
            {
                if (this.itemClearBackColor == value)
                    return;

                this.itemClearBackColor = value;
                this.Invalidate();
            }
        }

        private Color itemClearForeColor = Color.White;
        /// <summary>
        /// 清除按钮前景颜色
        /// </summary>
        [Description("清除按钮前景颜色")]
        [PropertyOrder(-190)]
        [DefaultValue(typeof(Color), "White")]
        public Color ItemClearForeColor
        {
            get { return this.itemClearForeColor; }
            set
            {
                if (this.itemClearForeColor == value)
                    return;

                this.itemClearForeColor = value;
                this.Invalidate();
            }
        }

        #endregion

        #region 字段

        private DropDownListPlus owner = null;

        #endregion

        public DropDownListPlusContentItemsStyle(DropDownListPlus owner)
        {
            this.owner = owner;
        }

        #region 私有方法

        /// <summary>
        /// 刷新控件
        /// </summary>
        public void Invalidate()
        {
            if (this.owner != null)
            {
                this.owner.Invalidate();
            }
        }

        /// <summary>
        /// 重新计算控件刷新控件
        /// </summary>
        public void InitializeInvalidate()
        {
            if (this.owner != null)
            {
                this.owner.InitializeRectangle();
                this.owner.Invalidate();
            }
        }

        #endregion

    }

}
